﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using CTP.Entitys;

namespace CTP
{
    [Guid("8d56f332-1387-41e9-98aa-aae7a9e3dff2")]
    [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    public interface ICTP
    {
        /// <summary>
        /// 注册回调
        /// </summary>
        /// <param name="client"></param>
        /// <returns></returns>      
        [ComVisible(false)]
        void RegisterCallback(ICTPCallbackHandle iCTPCallback);
       
        /// <summary>
        /// 卸载回调
        /// </summary>
        /// <param name="tradingAccount"></param>
        /// <param name="iCTPCallback"></param>
        [ComVisible(false)]
        void UnRegisterCallback( ICTPCallbackHandle iCTPCallback);

        /// <summary>
        /// 校验资金帐号
        /// </summary>
        /// <param name="account">资金帐号</param>
        /// <returns></returns>       
        int Login(TradingAccount account, int requestId);

        /// <summary>
        /// 登出资金账号
        /// </summary>
        /// <param name="account"></param>
        /// <param name="requestId"></param>
        int Logout(TradingAccount account, int requestId);

        /// <summary>
        /// 查询结算信息(帐户概览)
        /// <para>上期柜台用</para>
        /// </summary>
        /// <param name="account"></param>       
        int QuerySettlement(TradingAccount account, int requestId);

        /// <summary>
        /// 确认结算信息
        /// <para>上期柜台用</para>
        /// </summary>
        /// <param name="account"></param>       
        int ConfirmSettlement(TradingAccount account, int requestId);

        /// <summary>
        /// 查询帐户概览
        /// </summary>
        /// <param name="account">资金帐号</param>       
        int QueryAccountSummary(TradingAccount account, int requestId);

        /// <summary>
        /// 下单
        /// </summary>
        int PlaceOrder(TradingAccount account, Order ord, int requestId);

        /// <summary>
        /// 查单状态
        /// </summary>
        /// <param name="ord"></param>       
        int QueryOrderStatus(TradingAccount account, Order ord, int requestId);

        /// <summary>
        /// 撤单
        /// </summary>
        /// <param name="ord"></param>       
        int CancelOrder(TradingAccount account,  CancelOrderInfo order, int requestId);

        /// <summary>
        /// 查询当日委托
        /// </summary>
        /// <param name="account"></param>
        /// <param name="page"></param>       
        int QueryTodayOrder(TradingAccount account, PageInfo page, int requestId);

        /// <summary>
        /// 查询当日成交
        /// </summary>
        /// <param name="account"></param>
        /// <param name="page"></param>       
        int QueryTodayFilled(TradingAccount account, PageInfo page, int requestId);

        /// <summary>
        /// 查询持仓/库存
        /// </summary>
        /// <param name="account"></param>       
        int QueryPosition(TradingAccount account, int requestId);

        /// <summary>
        /// 校验资金帐号
        /// </summary>
        /// <param name="account">资金帐号</param>
        /// <returns></returns>       
        int LoginQoute(TradingAccount account, int requestId);

        /// <summary>
        /// 登出资金账号
        /// </summary>
        /// <param name="account"></param>
        /// <param name="requestId"></param>
        int LogoutQoute(TradingAccount account, int requestId);

        /// <summary>
        /// 订阅行情
        /// </summary>
        /// <param name="codes"></param>
        /// <returns></returns>
        int SubscribeQoute(string[] codes);

        /// <summary>
        /// 取消订阅行情
        /// </summary>
        /// <param name="codes"></param>
        /// <returns></returns>
        int UnSubscribeQoute(string[] codes);
        /// <summary>
        /// 获取指定账号是否已登陆
        /// </summary>
        /// <param name="account"></param>
        /// <returns></returns>
        bool GetIsLogined(string account);
        /// <summary>
        /// 获取指定账号是否已连接
        /// </summary>
        /// <param name="account"></param>
        /// <returns></returns>
        bool GetIsConnected(string account);
        /// <summary>
        /// 获取行情指定账号是否已登陆
        /// </summary>
        /// <param name="account"></param>
        /// <returns></returns>
        bool GetQouteIsLogined(string account);
        /// <summary>
        /// 获取行情指定账号是否已连接
        /// </summary>
        /// <param name="account"></param>
        /// <returns></returns>
        bool GetQouteIsConnected(string account);
    }

   


}
